home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / gjr / cmplrtst.lha / reptd.scm < prev    next >
Encoding:
Text File  |  1990-03-27  |  292 b   |  20 lines

  1. ;;; -*- Scheme -*-
  2.  
  3. #|
  4. Description:
  5. This code tests the closing code.
  6.  
  7. Usage:
  8. ((repeated 1+ 4) 5) -> 9
  9. |#
  10.  
  11. (declare (usual-integrations))
  12.  
  13. (define (repeated f n)
  14.   (define (loop m accum)
  15.     (if (zero? m)
  16.     accum
  17.     (loop (-1+ m)
  18.           (lambda (x)
  19.         (accum (f x))))))
  20.   (loop n (lambda (x) x)))